<template>
	<view class="page">
		<view class="list pad30_b">
			<view class="item border_bottom">
				<view>头像修改</view>
				<view style="width: 80rpx">
					<yqAvatar @upload="uploadHeadIcon" :inner="true" selWidth="600upx" selHeight="600upx" class="w80 h80" ref="avatar" :avatarSrc="info.url" />
				</view>
			</view>
		</view>
	</view>
</template>
<script>
import yqAvatar from './yq-avatar/yq-avatar.vue';
export default {
	components: {
		yqAvatar
	},

	data() {
		return {
			info: {
				url: 'https://image-files.gjszsc.com/icon-img/error_img_icon.png'
			}
		};
	},
	onPullDownRefresh() {},
	onLoad() {},
	methods: {
		uploadHeadIcon(e) {
			this.uploadImage([e.base64 || e.path]);
		},

		uploadImage(tempFilePaths) {
			console.log('tempFilePaths------------------' + JSON.stringify(tempFilePaths));
			let _this = this;
			uni.uploadFile({
				url: this.uploadImageUrl, //接口地址
				header: {
					token: uni.getStorageSync('token')
				}, //请求token
				filePath: tempFilePaths[0],
				name: 'file',
				success: res => {
					console.log('res', res);
					let data = JSON.parse(res.data);
					let url = data.data.fileUrl;

					this.info.url = url;

					uni.hideLoading();
				}
			});
		}
	}
};
</script>
<style lang="scss" scoped>
.page {
	padding: 28rpx 20rpx;
}

.list {
	background: #fff;
	border-radius: 20rpx;
	margin-bottom: 30rpx;

	.item {
		display: flex;

		align-items: center;
		justify-content: space-between;
		padding: 30rpx;

		> view:nth-child(2) {
			width: 70%;
			display: flex;
			align-items: center;
		}

		.uni-input {
			padding: 0rpx;
		}
	}
}
</style>
